<template>
    <div id="parts task">
        <div class="operation">
            <el-button v-if="menuId==='4594'" @click="insertList" class="slot-btn-top" type="primary" size="small">
                发放任务
            </el-button>
            <el-button v-if="menuId==='4594'" @click="insertTask('day')" class="slot-btn-top" type="primary"
                       size="small">每日任务
            </el-button>
            <el-button v-if="menuId==='4594'" @click="insertTask('week')" class="slot-btn-top" type="primary"
                       size="small">周总结
            </el-button>
             <el-button v-if="menuId==='4594'" @click="insertTask('month')" class="slot-btn-top" type="primary"
                       size="small">月总结
            </el-button>
            <el-button v-if="menuId==='4594'" @click="openInstructions" class="slot-btn-top" type="success" size="small"
                       style="position: absolute;top: 5px;right: 10px;">使用说明
            </el-button>
        </div>
        <el-table :data="menuId=='4594'?dataList.slice((dataPagination.currentPage-1)*dataPagination.pageSize,dataPagination.currentPage*dataPagination.pageSize):dataList" :row-class-name="tableRowClassName" :highlight-current-row="true" stripe border class="table-index" :height="tableHeight" style="width: 100%;" :header-cell-style="getRowClass" v-loading="loading">
            <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
            <el-table-column prop="taskName" label="任务名称" sortable min-width="240"></el-table-column>
            <el-table-column prop="creatorName" label="任务创建人" sortable min-width="130"></el-table-column>
            <el-table-column prop="performerName" label="任务执行人" sortable min-width="130"></el-table-column>
            <el-table-column prop="finishDate" label="需完成时间" sortable min-width="170"></el-table-column>
            <el-table-column prop="isReceived" label="任务是否接收" :formatter="formatNeedTrain" sortable min-width="140"></el-table-column>
            <el-table-column prop="receivedDate" label="任务接收创建时间" sortable min-width="170"></el-table-column>
            <el-table-column prop="startDate" label="任务实际开始时间" sortable min-width="170"></el-table-column>
            <el-table-column prop="endDate" label="任务实际结束时间" sortable min-width="170"></el-table-column>
            <el-table-column prop="taskResult" label="任务结果" :formatter="formatNeed2Train" sortable
                             min-width="130"></el-table-column>
            <el-table-column fixed="right" label="操作" sortable align="center" width="90">
                <template slot-scope="scope">
                    <el-button @click="updateList(scope.row)" type="text" size="small">编辑</el-button>
                    <el-button @click="deleteList(scope.row)" type="text" size="small">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                       :current-page="dataPagination.currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="dataPagination.pageSize"
                       layout="total, sizes, prev, pager, next, jumper" :total="dataPagination.total"></el-pagination>

        <!-- 详情信息 -->
        <el-dialog :title="dialogTitle" width="90%" top="30px" :visible.sync="isDialog" :close-on-click-modal="false">
            <el-tabs v-model="activeName" @tab-click="handleClick" style="padding-bottom: 15px;">
                <el-tab-pane v-if="!isEveryDayTask" label="任务信息" name="1" class="dialog1" :style="dialogHeightPane">
                    <h3 class="dialog-plate-title"><span>1、基本信息</span></h3>
                    <el-form :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right"
                             label-width="180px" style="margin-bottom: 0;">
                        <el-form-item label="*任务名称">
                            <el-input v-model="dialogList.taskName" :disabled="!dialogListDisabled.taskName"></el-input>
                        </el-form-item>
                        <el-form-item label="*完成时间">
                            <el-date-picker v-model="dialogList.finishDate" :disabled="!dialogListDisabled.finishDate"
                                            format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间"
                                            style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="*任务执行人所属部门">
                            <el-select v-model="dialogList.dept" :disabled="!dialogListDisabled.dept"
                                       @change="changeDept">
                                <el-option v-for="item in deptors" :key="item.id" :label="item.deptName"
                                           :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="*任务执行人">
                            <el-select v-model="dialogList.performer" :disabled="!dialogListDisabled.performer">
                                <el-option v-for="item in performName" :key="item.id" :label="item.name"
                                           :value="item.id"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="任务创建人">
                            <el-input v-model="dialogList.creatorName"
                                      :disabled="!dialogListDisabled.creatorName"></el-input>
                        </el-form-item>
                        <el-form-item label="任务创建时间">
                            <el-input v-model="dialogList.createDate"
                                      :disabled="!dialogListDisabled.createDate"></el-input>
                        </el-form-item>
                    </el-form>
                    <el-form v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="任务说明">
                            <el-button v-if="dialogType === '2'"  @click="insertMissionList" :disabled="!(menuId=='4594')" type="primary" size="small" style="margin-top: 20px;">新增任务说明</el-button>
                            <el-table v-if="dialogType === '2'" :data="missionData" stripe border class="table-index" height="150" style="width: 99%;" :header-cell-style="getRowClass">
                                <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                                <el-table-column prop="time" label="填写时间" sortable min-width="170"></el-table-column>
                                <el-table-column prop="content" label="填写内容" :formatter="formatterContentHtml" sortable min-width="500"></el-table-column>
                                <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                                    <template slot-scope="scope">
                                        <el-button @click="updateMissionList(scope.row)" :disabled="!dialogListDisabled.taskContent" type="text" size="small">编辑</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <quill-editor  v-if="dialogType === '1'"  class="task" v-model="dialogList.taskContent"
                                           @focus="!dialogListDisabled.taskContent? onEditorFocus($event) : ''"
                                           style="padding-right: 10px;"></quill-editor>
                        </el-form-item>
                    </el-form>

                    <h3 v-if="dialogType !== '1'" class="dialog-plate-title" ><span>2、接收信息</span></h3>
                    <el-form v-if="dialogType !== '1'" :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right"
                             label-width="180px" style="margin-bottom: 0;">
                        <el-form-item label="任务是否接收">
                            <el-select v-model="dialogList.isReceived" :disabled="!dialogListDisabled.isReceived">
                                <el-option label="【空】" value="-1"></el-option>
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="接收创建时间">
                            <el-date-picker v-model="dialogList.receivedDate"
                                            :disabled="!dialogListDisabled.receivedDate" format="yyyy-MM-dd HH:mm:ss"
                                            type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                        </el-form-item>
                    </el-form>
                    <el-form v-if="dialogType !== '1'" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="任务接收说明">
                            <el-button  @click="insertMissionReceiveList" :disabled="!dialogListDisabled.receivedDescription" type="primary" size="small" style="margin-top: 20px;">新增任务说明</el-button>
                            <el-table :data="missionReceiveData" stripe border class="table-index" height="150" style="width: 99%;" :header-cell-style="getRowClass">
                                <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                                <el-table-column prop="time" label="填写时间" sortable min-width="170"></el-table-column>
                                <el-table-column prop="content" label="填写内容" :formatter="formatterContentHtml" sortable min-width="500"></el-table-column>
                                <el-table-column fixed="right" label="操作" sortable align="center" width="75">
                                    <template slot-scope="scope">
                                        <el-button @click="updateMissionReceiveList(scope.row)" :disabled="!dialogListDisabled.receivedDescription" type="text" size="small">编辑</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </el-form-item>
                    </el-form>


                    <h3 v-if="dialogType !== '1'" class="dialog-plate-title"><span>3、开始信息</span></h3>
                    <el-form v-if="dialogType !== '1'" :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right"
                             label-width="180px" style="margin-bottom: 0;">
                        <el-form-item label="任务实际开始时间">
                            <el-date-picker v-model="dialogList.startDate" :disabled="!dialogListDisabled.startDate"
                                            format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间"
                                            style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="开始创建时间">
                            <el-input v-model="dialogList.startCreateDate"
                                      :disabled="!dialogListDisabled.startCreateDate"></el-input>
                        </el-form-item>
                    </el-form>



                    <h3 v-if="dialogType !== '1'" class="dialog-plate-title"><span>5、结束信息</span></h3>
                    <el-form v-if="dialogType !== '1'" :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right"
                             label-width="180px" style="margin-bottom: 0;">
                        <el-form-item label="任务实际结束时间">
                            <el-date-picker v-model="dialogList.endDate" :disabled="!dialogListDisabled.endDate"
                                            format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间"
                                            style="width: 200px;"></el-date-picker>
                        </el-form-item>
                        <el-form-item label="结束创建时间">
                            <el-input v-model="dialogList.endDateCreateDate"
                                      :disabled="!dialogListDisabled.endDateCreateDate"></el-input>
                        </el-form-item>
                        <el-form-item label="任务结果">
                            <el-select v-model="dialogList.taskResult" :disabled="!dialogListDisabled.taskResult">
                                <el-option label="【空】" value="-1"></el-option>
                                <el-option label="完成" value="1"></el-option>
                                <el-option label="未完成" value="0"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="自我评价">
                            <el-select v-model="dialogList.taskSelfEvaluation"
                                       :disabled="!dialogListDisabled.taskSelfEvaluation">
                                <el-option label="【空】" value="-1"></el-option>
                                <el-option label="差" value="1"></el-option>
                                <el-option label="良好" value="2"></el-option>
                                <el-option label="优秀" value="3"></el-option>
                            </el-select>
                        </el-form-item>
                    </el-form>
                    <el-form v-if="dialogType !== '1'" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="自我评价说明">
                            <quill-editor class="task" v-model="dialogList.taskSelfDescription"
                                          @focus="!dialogListDisabled.taskSelfDescription? onEditorFocus($event) : ''"
                                          style="padding-right: 10px;"></quill-editor>
                        </el-form-item>
                    </el-form>





                    <h3 v-if="dialogType !== '1'" class="dialog-plate-title"><span>6、复核信息</span></h3>
                    <el-form v-if="dialogType !== '1'" :inline="true" class="demo-form-inline" v-model="dialogList" label-position="right" label-width="180px" style="margin-bottom: 0;">
                        <el-form-item label="任务是否复核">
                            <el-select v-model="dialogList.isReviewTask" :disabled="!dialogListDisabled.isReviewTask">
                                <el-option label="【空】" value="-1"></el-option>
                                <el-option label="否" value="0"></el-option>
                                <el-option label="是" value="1"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="复核结果">
                            <el-select v-model="dialogList.reviewResult" :disabled="!dialogListDisabled.reviewResult">
                                <el-option label="【空】" value="-1"></el-option>
                                <el-option label="通过" value="1"></el-option>
                                <el-option label="不通过" value="0"></el-option>
                            </el-select>
                        </el-form-item>
                        <el-form-item label="复核创建时间">
                            <el-input v-model="dialogList.reviewTime"
                                      :disabled="!dialogListDisabled.reviewTime"></el-input>
                        </el-form-item>
                    </el-form>
                    <el-form v-if="dialogType !== '1'" v-model="dialogList" label-position="right" label-width="180px">
                        <el-form-item label="任务复核说明">

                            <quill-editor class="task" v-model="dialogList.reviewDescription"
                                          @focus="!dialogListDisabled.reviewDescription? onEditorFocus($event) : ''"
                                          style="padding-right: 10px;"></quill-editor>

                            <!--<el-input v-model="dialogList.reviewDescription"-->
                            <!--:disabled="!dialogListDisabled.reviewDescription" type="textarea" size="middle"-->
                            <!--style="width: 95%;"></el-input>-->
                        </el-form-item>
                    </el-form>
                    <div style="text-align: right;margin-right: 1%;">
                        <el-button @click="submitList" :disabled="!dialogBtn" type="primary">确 定</el-button>
                    </div>


                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'" label="4、过程信息" name="2" :style="dialogHeightPane">
                    <el-button v-if="menuId!=='4594'" @click="insertProcessStateList" type="primary" size="small">新增
                    </el-button>
                    <el-table :data="processStateData" stripe border class="table-index" :max-height="dialogTableHeight" style="width: 100%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40" align="center"></el-table-column>
                        <el-table-column prop="taskDescription" label="任务说明" show-overflow-tooltip sortable min-width="280" align="center"></el-table-column>
                        <el-table-column prop="startDate" label="开始时间" sortable min-width="170" align="center"></el-table-column>
                        <el-table-column prop="endDate" label="结束时间" sortable min-width="170" align="center"></el-table-column>
                        <el-table-column prop="creatTime" label="创建时间" sortable min-width="170" align="center"></el-table-column>
                        <el-table-column prop="managerName" label="主管" sortable align="center"></el-table-column>
                        <el-table-column prop="managerAdvice" label="主管意见" show-overflow-tooltip sortable min-width="200" align="center"></el-table-column>
                        <el-table-column  label="类型" min-width="60" align="center">
                            <template slot-scope="scope">
                                <el-tag v-if="scope.row.isNowTime==='1'"  size="mini" type="success">实时</el-tag>
                                <el-tag type="info" v-else size="mini">补录</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column  label="状态" min-width="100" align="center">
                            <template slot-scope="scope">
                                <el-tag v-if="scope.row.endDate" type="success" size="mini"  :hit="true">已完成</el-tag>
                                <el-tag type="danger" v-else size="mini" :hit="true">进行中...</el-tag>
                            </template>
                        </el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="center" width="200">
                            <template slot-scope="scope">
                                <el-button size="small" type="text" @click="finishProcess(scope.row)"  v-if="scope.row.isNowTime==='1'&&!scope.row.endDate">结束</el-button>
                                <el-button size="small" type="text" @click="updateProcessStateList(scope.row)" >编辑</el-button>
                                <el-button size="small" type="text" @click="deleteProcessStateList(scope.row)" >删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane v-if="dialogType !== '1'" label="附件" name="3" :style="dialogHeightPane">
                    <!-- 附件上传按钮 -->
                    <div style="overflow: hidden;margin-bottom: 20px;">
                        <el-upload class="upload-demo" style="width: 99%;margin: 0 auto;" ref="uploadEnclosure"
                                   :action="enclosureSrc" :data="resEnclosureData" :headers="headers" :auto-upload="false" :limit="1" :on-success="uploadEnclosureSuccess">
                            <el-button  slot="trigger" size="small" type="primary">上传附件</el-button>
                        </el-upload>
                    </div>
                    <el-form label-position="right" label-width="110px" :model="enclosureData">
                        <el-form-item label="文件描述"><el-input v-model="enclosureData.fileDesc" @blur="changeFileDesc" type="textarea" style="padding-right: 10px;box-sizing: border-box;"></el-input></el-form-item>
                    </el-form>
                    <div style="margin-top: 20px;text-align: right;padding-right: 10px;"><el-button  @click="submitDialogEnclosureDataOther" type="primary">提交</el-button></div>

                    <!-- 附件列表 -->
                    <h3 class="dialog-plate-title" style="margin: 0px 0 10px;padding-right: 10px;box-sizing: border-box;"><span>已上传附件列表</span></h3>
                    <el-table :data="enclosureList" stripe border class="user-table" height="550" style="width: 99%;" :header-cell-style="getRowClass">
                        <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
                        <el-table-column prop="fileName" label="文件名称" sortable min-width="300"></el-table-column>
                        <el-table-column prop="uploadPersonName" label="文件上传人" sortable min-width="130"></el-table-column>
                        <el-table-column prop="uploadTime" label="文件上传时间" sortable min-width="170"></el-table-column>
                        <el-table-column prop="fileDesc" label="文件描述" sortable min-width="400"></el-table-column>
                        <el-table-column fixed="right" label="操作" sortable align="right" min-width="90">
                            <template slot-scope="scope">
                                <el-button @click="downloadAppendix(scope.row.id)" type="text" size="small">下载</el-button>
                                <el-button @click="deleteEnclosureList(scope.row)" type="text" size="small">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
            </el-tabs>
        </el-dialog>

        <!-- 过程状态信息 -->
        <el-dialog :title="dialogProcessStateTitle" width="900px" center :visible.sync="isProcessStateDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <h3 class="dialog-plate-title"><span>基本信息</span></h3>
            <el-form  :model="dialogProcessStateList" label-position="right" label-width="180px" :rules="processRules" ref="dialogProcessStateList">
                <el-form-item label="任务说明"  prop="taskDescription">
                    <el-input v-model="dialogProcessStateList.taskDescription" type="textarea" mini="middle" placeholder="请输入任务说明"></el-input>
                </el-form-item>
                <el-form-item label="实时时间">
                    <el-switch v-model="dialogProcessStateList.isNowTime" active-value='1' inactive-value="0" @change="changeNowTime" :disabled="dialogProcessStateTitle==='编辑'"></el-switch>
                </el-form-item>
                <el-form-item label="开始时间" prop="startDate">
                    <el-date-picker v-model="dialogProcessStateList.startDate" format="yyyy-MM-dd HH:mm:ss"
                     type="datetime" placeholder="选择日期时间" style="width: 200px;" :disabled="dialogProcessStateList.isNowTime==='1'" ></el-date-picker>
                     <el-button type="text" @click="getNowDateStart" v-if="dialogProcessStateList.isNowTime!=='1'">获取当前时间</el-button>
                </el-form-item>
                <el-form-item label="结束时间" prop="endDate" v-if="dialogProcessStateTitle==='编辑'||dialogProcessStateList.isNowTime==='0'">
                    <el-date-picker ref="jieshushijian" v-model="dialogProcessStateList.endDate" format="yyyy-MM-dd HH:mm:ss" type="datetime" placeholder="选择日期时间" style="width: 200px;"></el-date-picker>
                    <el-button type="text" @click="getNowDateFinished">获取当前时间</el-button>
                </el-form-item>
                <el-form-item label="创建时间"  >
                    <el-input v-model="dialogProcessStateList.creatTime" disabled></el-input>
                </el-form-item>
                <h3 class="dialog-plate-title"><span>主管评审</span></h3>
                 <el-col :span="12">
                    <el-form-item label="主管" >
                        <el-input v-model="dialogProcessStateList.managerName"  disabled></el-input>
                    </el-form-item>
                 </el-col>
                 <el-col :span="12">
                    <el-form-item label="创建时间" >
                        <el-input v-model="dialogProcessStateList.adviceCreattime" disabled></el-input>
                    </el-form-item>
                 </el-col>
                  <el-form-item label="主管意见" >
                    <el-input v-model="dialogProcessStateList.managerAdvice"
                              :disabled="dialogProcessStateTitle==='添加'" type="textarea" mini="middle"
                              style='width: 88%;'></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button :disabled="!isProcessStateSubmitBtn" @click="submitProcessStateList('dialogProcessStateList')" type="primary">确 定</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>


        <!-- 任务说明 -->
        <el-dialog :title="dialogMissionTitle" width="600px" center :visible.sync="isMissionDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <el-form :inline="true" class="demo-form-inline" v-model="dialogMissionList" label-position="right" label-width="180px">
                <el-form-item label="填写内容">
                    <quill-editor v-model="dialogMissionList.content" style="padding-right: 10px;"></quill-editor>
                    <!--<el-input type="textarea" :rows="8" v-model="dialogMissionList.content"-->
                    <!--style="width: 355px;"></el-input>-->
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align: right;"><el-button :disabled="!dialogMissionBtn"  @click="submitMissionList" type="primary">确 定</el-button></div>
        </el-dialog>

        <!-- 任务接收说明 -->
        <el-dialog :title="dialogMissionReceiveTitle" width="600px" center :visible.sync="isMissionReceiveDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <el-form :inline="true" class="demo-form-inline" v-model="dialogMissionReceiveList" label-position="right" label-width="180px">
                <el-form-item label="填写内容">
                    <quill-editor v-model="dialogMissionReceiveList.content" style="padding-right: 10px;"></quill-editor>
                    <!--<el-input type="textarea" :rows="8" v-model="dialogMissionReceiveList.content"
                              style="width: 355px;"></el-input>-->
                </el-form-item>
            </el-form>
            <div slot="footer" class="dialog-footer" style="text-align: right;"><el-button :disabled="!dialogMissionReceiveBtn" @click="submitMissionReceiveList" type="primary">确 定</el-button></div>
        </el-dialog>

        <!-- 使用说明 -->
        <el-dialog title="使用说明" width="1000px" top="50px" :visible.sync="isInstructionsDialog" :close-on-click-modal="false" style="padding-bottom: 15px;">
            <div :style="instructionsHeight">
                <div style="overflow: hidden;margin-bottom: 20px;">
                    <el-upload class="upload-demo"
                               style="width: 99%;margin: 0 auto;"
                               ref="uploadDraw"
                               :action="appendixUrl"
                               :auto-upload="false"
                               :on-success="uploadDrawSuccess"
                               :on-error="uploadDrawError"
                               :limit="1">
                        <el-button slot="trigger"
                                   size="small"
                                   type="primary"
                        >上传图纸文件</el-button>
                    </el-upload>
                </div>
                <div style="overflow: hidden;">
                    <div style="width: 99%;margin: 0 auto;">
                        <el-input v-model.number="drawingPage" type="number" style="width: 150px;" min="1" :max="drawingNumPages"></el-input>
                        <span>/{{drawingNumPages}}</span>
                        <el-button @click="drawingRotate += 90">&#x27F3;</el-button>
                        <el-button @click="downloadAppendixPDF">下载</el-button>
                        <pdf ref="drawingPdf"
                             style="border: 1px solid red;"
                             :src="tableDialogData.drawingSrc"
                             :page="drawingPage"
                             :rotate="drawingRotate" @progress="drawingLoadedRatio = $event" @num-pages="drawingNumPages = $event" @link-clicked="drawingPage = $event">
                        </pdf>
                    </div>
                </div>
            </div>
            <div slot="footer" class="dialog-footer" style="text-align: right;">
                <el-button :disabled="!dialogInstructionsBtn" @click="submitInstructions" type="primary">确 定</el-button>
            </div>
        </el-dialog>

    </div>
</template>

<script>
    const Ip = 'http://192.168.0.93:8889';
    import pdf from 'vue-pdf';
    import 'quill/dist/quill.core.css';
    import 'quill/dist/quill.snow.css';
    import 'quill/dist/quill.bubble.css';
    import {quillEditor} from 'vue-quill-editor';
    import api from '@/axios/api.js'
    export default {
        name: "",
        components: {pdf,quillEditor},
        data() {
            let token = sessionStorage.getItem("tokenId");
            let menuId = sessionStorage.getItem('menuId');
            let tableHeight = menuId === '4594' ? (document.documentElement.clientHeight - 160) : (document.documentElement.clientHeight - 130);
            return {
                tokenId: token,
                menuId: menuId,
                activeName: '1',
                performName: [],
                deptors: [],
                tableHeight: tableHeight,
                dataList: [],
                dataPagination:{
                    pageSize:10,
                    currentPage:1,
                    total:0
                },
                loading:false,
                //基本信息
                isDialog: false,
                dialogTitle: '',
                dialogBtn: true,
                dialogType: '',
                dialogHeightPane: {
                    height: (document.documentElement.clientHeight - 180) + 'px',
                    overflowY: 'auto'
                },
                dialogTableHeight: document.documentElement.clientHeight - 260,
                dialogList: {
                    isEveryDayTask: '',
                    isReviewTask: '',
                    reviewResult: '',
                    reviewTime: '',
                    reviewDescription: '',
                    createDate: '',
                    creator: '',
                    creatorName: '',
                    dept: '',
                    deptName: '',
                    endDate: '',
                    endDateCreateDate: '',
                    finishDate: '',
                    id: '',
                    isReceived: '',
                    performer: '',
                    performerName: '',
                    receivedDate: '',
                    receivedDescription: '',
                    startCreateDate: '',
                    startDate: '',
                    taskContent: '',
                    taskName: '',
                    taskResult: '',
                    taskSelfDescription: '',
                    taskSelfEvaluation: '',
                    taskState: '',
                },
                dialogListDisabled: {
                    isEveryDayTask:true,
                    isReviewTask: true,
                    reviewResult: true,
                    reviewTime: true,
                    reviewDescription: true,
                    createDate: true,
                    creator: true,
                    creatorName: true,
                    dept: true,
                    deptName: true,
                    endDate: true,
                    endDateCreateDate: true,
                    finishDate: true,
                    id: true,
                    isReceived: true,
                    performer: true,
                    performerName: true,
                    receivedDate: true,
                    receivedDescription: true,
                    startCreateDate: true,
                    startDate: true,
                    taskContent: true,
                    taskName: true,
                    taskResult: true,
                    taskSelfDescription: true,
                    taskSelfEvaluation: true,
                    taskState: true,
                },
                isEveryDayTask: true,


                //附件
                enclosureSrc: '/adscm/operation/taskManagerAttchment/upload',
                headers: {'deviceCode': 'A95ZEF1-47B5-AC90BF3'},
                resEnclosureData: {taskManagerAttchment: ''},
                enclosureData: {
                    id:"",
                    tid:"",
                    fileName:"",
                    filePath:"",
                    fileDesc:"",
                    uploadTime:"",
                    uploadPerson:"",
                },
                enclosureList: [],


                //过程状态信息
                isProcessStateDialog: false,
                dialogProcessStateTitle: '',
                dialogProcessStateList: {
                    adviceCreattime: "",
                    creatTime: "",
                    creator: "",
                    endDate: "",
                    id: "",
                    manager: "",
                    managerAdvice: "",
                    isNowTime: '1',/**实时开始时间*/
                    managerName: "",
                    startDate: "",
                    taskDescription: "",
                    taskId: "",
                },
                /**过程信息验证信息 */
                processRules:{
                    taskDescription:[{required: true, message: '任务说明不能为空', trigger: 'blur' }],
                    startDate:[{required: true, message: '请选择开始时间', trigger: 'change' }]
                },
                processStateData: [],
                isProcessStateSubmitBtn: true,
                startChecked: false,
                endChecked: false,


                //任务说明
                isMissionDialog: false,
                dialogMissionTitle: '',
                dialogMissionBtn: true,
                dialogMissionList: {
                    content: '',
                    id: '',
                    object: '',
                    person: '',
                    personName: '',
                    tid: '',
                    time: '',
                    type: '',
                },
                missionData: [],


                //任务接收说明
                isMissionReceiveDialog: false,
                dialogMissionReceiveTitle: '',
                dialogMissionReceiveBtn: true,
                dialogMissionReceiveList: {
                    content: '',
                    id: '',
                    object: '',
                    person: '',
                    personName: '',
                    tid: '',
                    time: '',
                    type: '',
                },
                missionReceiveData: [],

                //使用说明
                jurisdiction:{
                    updateSoftDescription:true
                },
                isInstructionsDialog:false,
                dialogInstructionsBtn: true,
                instructionsHeight: {
                    height: (document.documentElement.clientHeight - 210) + 'px',
                    overflowY: 'auto'
                },
                isInstructionsBtn:true,
                instructions:{
                    content: '',
                    id: '',
                    type: '',
                },
                //PDF
                drawingLoadedRatio: 0,
                drawingPage: 1,
                drawingNumPages: 0,
                drawingRotate: 0,
                appendixUrl:"/api/adscm/operation/jySoftDescription/upload/1",
                tableDialogData: {
                    drawingPath: "",
                    drawingSrc: ''
                },

            };
        },
        created() {
            this.getData();
            this.getDepts();
            // this.getInstructions();
            this.getJurisdiction();
        },
        methods: {
            getNowDateStart(){/**开始时间点击获取当前时间 */
                this.dialogProcessStateList.startDate=this.getNowTime();

            },
            getNowDateFinished(){/**结束时间点击获取当前时间 */
                this.dialogProcessStateList.endDate=this.getNowTime();

            },
            getDepts() {
                let _this = this;
                api.selectDepts().then(res=>{
                    _this.deptors = res.content;
                })
            },
            getPerform(id) {
                let _this = this;
                api.taskPerformPerson(id).then(res=>{
                     _this.performName = res.content;
                });
            },
            getData() {
                let _this = this;
                let type='';
                _this.loading = true;
                switch(_this.menuId ){
                    case '4594'://获取下发交办任务列表
                        api.assignmentList().then(res=>{
                            _this.loading=false;
                            _this.dataList = res.content;
                        },error=>{
                             _this.loading=false;
                        })
                        return
                    break;
                    case '4592'://0-待办交办任务
                        type=0;
                    break;
                    case '4593'://1-已办交办任务
                        type=1;
                    break;
                }
                 api.getMyTaskManager(type,{
                     pageSize:_this.dataPagination.pageSize,
                     currentPage:_this.dataPagination.currentPage,
                 }).then(res=>{
                    _this.dataList = res.content.records;
                    _this.dataPagination.total=res.content.total;
                    _this.loading=false;
                 },error=>{
                      _this.loading=false;
                 })
            },
            changeDept() {
                this.getPerform(this.dialogList.dept)
            },
            insertList() {
                this.isDialog = true;
                this.dialogType = '1';
                this.isEveryDayTask = false;
                this.dialogListDisabled = {
                    isReviewTask: false,
                    reviewResult: false,
                    reviewTime: false,
                    reviewDescription: false,
                    createDate: false,
                    creator: false,
                    creatorName: false,
                    dept: true,
                    deptName: false,
                    endDate: false,
                    endDateCreateDate: false,
                    finishDate: true,
                    id: false,
                    isReceived: false,
                    performer: true,
                    performerName: true,
                    receivedDate: false,
                    receivedDescription: false,
                    startCreateDate: false,
                    startDate: false,
                    taskContent: true,
                    taskName: true,
                    taskResult: false,
                    taskSelfDescription: false,
                    taskSelfEvaluation: false,
                    taskState: false,
                    isEveryDayTask: false,
                };
                this.dialogList = {
                    isEveryDayTask: '',
                    isReviewTask: '',
                    reviewResult: '',
                    reviewTime: '',
                    reviewDescription: '',
                    createDate: '',
                    creator: '',
                    creatorName: '',
                    dept: 1,
                    deptName: '',
                    endDate: '',
                    endDateCreateDate: '',
                    finishDate: '',
                    id: '',
                    isReceived: '',
                    performer: '',
                    performerName: '',
                    receivedDate: '',
                    receivedDescription: '',
                    startCreateDate: '',
                    startDate: '',
                    taskContent: '',
                    taskName: '',
                    taskResult: '',
                    taskSelfDescription: '',
                    taskSelfEvaluation: '',
                    taskState: '',
                };
                this.getPerform(this.deptors[0].id)
            },
            insertTask(type){
                let self = this;
                self.$confirm(`是否生成${type==='day'?'每日任务':type==='week'?'周总结':'月总结'}`,{
                      confirmButtonClass: 'el-button--warning'
                }).then(()=>{
                    switch(type){
                        case 'day':
                            api.insertEverDayTask().then(res=>{
                                self.$message.success('已经创办每日任务！');
                            });
                        break;
                        case 'week':
                            api.insertWeekTask().then(res=>{
                                self.$message.success('已经创建周总结！');
                            })
                        break;
                        case 'month':
                            api.insertMonthTask().then(res=>{
                                self.$message.success('已经创建月总结！');
                            })
                        break;
                    }
                })
            },
            updateList(row) {
                let _this = this;
                let url;
                if (_this.menuId==='4594') {
                    url = '/api/adscm/operation/taskManager/creatorSelected/'+row.id+'?tokenId='+_this.tokenId;
                } else if (_this.menuId==='4592' || _this.menuId==='4593') {
                    url = '/api/adscm/operation/taskManager/performerSelected/'+row.id+'?tokenId='+_this.tokenId;
                }
                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isDialog = true;
                        _this.dialogType = '2';
                        _this.activeName = row.isEveryDayTask == 1 ? '2' : '1';
                        _this.isEveryDayTask = row.isEveryDayTask == 1 ? true : false;
                        _this.dialogListDisabled = {
                            isReviewTask: (_this.menuId === '4594' && row.isReceived == 1) ? true : false,
                            reviewResult: (_this.menuId === '4594' && row.isReceived == 1) ? true : false,
                            reviewDescription: (_this.menuId === '4594' && row.isReceived == 1) ? true : false,
                            reviewTime: false,
                            createDate: false,
                            creator: false,
                            creatorName: false,
                            dept: _this.menuId === '4594' ? (row.isReceived != 1 ? true : false) : false,
                            deptName: _this.menuId === '4594' ? (row.isReceived != 1 ? true : false) : false,
                            endDate: _this.menuId === '4592' ? true : false,
                            endDateCreateDate: false,
                            finishDate: _this.menuId === '4594' ? (row.isReceived != 1 ? true : false) : false,
                            id: false,
                            isReceived: _this.menuId === '4592' ? true : false,
                            performer: _this.menuId === '4594' ? (row.isReceived != 1 ? true : false) : false,
                            performerName: _this.menuId === '4594' ? (row.isReceived != 1 ? true : false) : false,
                            receivedDate: false,
                            receivedDescription: _this.menuId === '4592' ? true : false,
                            startCreateDate: false,
                            startDate: _this.menuId === '4592' ? true : false,
                            taskContent: _this.menuId === '4594' ? (row.isReceived != 1 ? true : false) : false,
                            taskName: _this.menuId === '4594' ? (row.isReceived != 1 ? true : false) : false,
                            taskResult: _this.menuId === '4592' ? true : false,
                            taskSelfDescription: _this.menuId === '4592' ? true : false,
                            taskSelfEvaluation: _this.menuId === '4592' ? true : false,
                            taskState: false,
                        };
                        _this.dialogList = row;
                        if (row.isEveryDayTask == 1) {
                            _this.getProcessStateData();
                        }
                        _this.getMissionData();
                        _this.getMissionReceiveData();
                        _this.dialogList.dept = parseInt(_this.dialogList.dept);
                        _this.dialogList.performer = parseInt(_this.dialogList.performer);
                        _this.dialogList.isReceived = _this.dialogList.isReceived ? _this.dialogList.isReceived.toString() : '';
                        _this.getPerform(_this.dialogList.dept);
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })

            },
            deleteList(row) {
                console.log( row )
                let _this = this;
                let url;
                if (_this.menuId==='4594') {
                    url='/api/adscm/operation/taskManager/delete/'+row.id+'?tokenId=' + _this.tokenId;
                } else  if (_this.menuId==='4592') {
                    url='/api/adscm/operation/taskManager/deleteDB/'+row.id+'?tokenId=' + _this.tokenId;
                }

                this.$confirm('是否删除此任务？', '提示', {
                    confirmButtonClass: 'el-button--warning'
                }).then(() => {
                    this.$http({
                        url: url,
                        method: 'post',
                        headers: {'X-Requested-With': 'XMLHttpRequest'}
                    }).then(function (res) {
                        if (res.data.statusCode == 200) {
                            _this.getData();
                        } else {
                            _this.$message.error(res.data.desc);
                        }
                    }).catch(function (catchres) {
                        _this.$message.error("加载失败！请重新加载...");
                    })
                }).catch(() => {});


            },
            submitList() {
                let _this = this;
                let url;
                if (_this.dialogType === '1') {
                    url = '/api/adscm/operation/taskManager/insert?tokenId=' + _this.tokenId;
                } else if (_this.dialogType === '2') {
                    url = '/api/adscm/operation/taskManager/update?tokenId=' + _this.tokenId;
                }
                _this.dialogList.finishDate = _this.timestampToTime(_this.dialogList.finishDate);
                _this.dialogList.startDate = _this.timestampToTime(_this.dialogList.startDate);
                _this.dialogList.endDate = _this.timestampToTime(_this.dialogList.endDate);
                if ( _this.dialogList.taskName === '') {
                    _this.$message.error("任务名称不能为空！");
                } else if ( _this.dialogList.finishDate === '') {
                    _this.$message.error("完成时间不能为空！");
                } else if ( _this.dialogList.dept === '') {
                    _this.$message.error("任务执行人所属部门不能为空！");
                } else if ( _this.dialogList.performer === '') {
                    _this.$message.error("任务执行人不能为空！");
                } else{
                    _this.dialogBtn = false;
                    this.$http({
                        url: url,
                        method: 'post',
                        headers: {'X-Requested-With': 'XMLHttpRequest'},
                        data: _this.dialogList,
                    }).then(function (res) {
                        if (res.data.statusCode == 200) {
                            _this.isDialog = false;
                            _this.getData();

                        } else {
                            _this.$message.error(res.data.desc);
                        }
                        _this.dialogBtn = true;
                    }).catch(function (catchres) {
                        _this.$message.error("加载失败！请重新加载...");
                        _this.dialogBtn = true;
                    })
                }
            },


            //附件
            getEnclosureData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/operation/taskManagerAttchment/selectByFileId/' + _this.dialogList.id + '?tokenId='+_this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {

                    console.log( res.data )

                    if (res.data.statusCode == 200) {
                        _this.enclosureList = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            uploadEnclosureSuccess(response, file, fileList) {
                console.log( response )
                if (response.statusCode == 200) {
                    this.$refs.uploadEnclosure.clearFiles();
                    this.enclosureData.fileDesc = "";
                    this.getEnclosureData();
                } else {
                    this.$message.error(response.desc)
                }
            },
            changeFileDesc() {
                this.enclosureData.tid = this.dialogList.id;
                this.resEnclosureData = {taskManagerAttchment: JSON.stringify(this.enclosureData)};
            },
            submitDialogEnclosureDataOther() {
                this.resEnclosureData = {taskManagerAttchment: JSON.stringify(this.enclosureData)};
                this.$refs.uploadEnclosure.submit();
            },
            downloadAppendix(id) {
                window.location.href = "/api/adscm/operation/taskManagerAttchment/download/" + id;
            },
            deleteEnclosureList(row){
                let _this = this;
                this.$confirm('是否删除此文件?', '提示', {
                    confirmButtonClass: 'el-button--warning'
                }).then(() => {
                    _this.$http({
                        url: '/api/adscm/operation/taskManagerAttchment/delete/'+row.id+'?tokenId='+_this.tokenId,
                        method: 'post',
                        headers: {'X-Requested-With': 'XMLHttpRequest'},
                    }).then(function (res) {
                        if (res.data.statusCode == 200) {
                            _this.getEnclosureData();
                        } else {
                            _this.$message.error(res.data.desc);
                        }
                    }).catch(function (catchres) {_this.$message.error("加载失败！请重新加载...");
                    })
                }).catch(() => {});
            },


            //过程状态信息
            getProcessStateData() {
                let _this = this;
                api.taskManagerdetail(_this.dialogList.id ).then(res=>{
                    _this.processStateData = res.content;
                    console.log(_this.processStateData.length);
                })
            },
            insertProcessStateList() {
                this.isProcessStateDialog = true;
                this.dialogProcessStateTitle = '添加';
                this.dialogProcessStateList = {
                    adviceCreattime: "",
                    creatTime: "",
                    creator: "",
                    endDate: "",
                    isNowTime: '1',
                    id: "",
                    manager: "",
                    managerAdvice: "",
                    managerName: "",
                    startDate: this.getNowTime(),
                    taskDescription: "",
                    taskId: this.dialogList.id,
                };
            },
            updateProcessStateList(row) {
                this.isProcessStateDialog = true;
                this.dialogProcessStateTitle = '编辑';
                this.dialogProcessStateList = row;
            },
            deleteProcessStateList(row) {
                let _this = this;
                this.$confirm('是否删除本次任务过程信息?', '提示', {
                    confirmButtonClass: 'el-button--warning'
                }).then(() => {
                    api.deleteTaskDetail(row.id).then(res=>{
                         _this.getProcessStateData();
                         _this.$message.success("删除成功！")
                    });
                }).catch(() => {});
            },
            changeNowTime(value){/**实时更改 */
                let self=this;
                self.dialogProcessStateList.isNowTime=value;
                self.dialogProcessStateList.startDate= value=='1'?self.getNowTime():'';
            },
            getNowTime(){/**获取当前时间 */
            let date = new Date();
                let Y = date.getFullYear() + '-';
                let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " ";
                let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":";
                let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
                let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
                let thisTime = Y + M + D + h + m + s;
                return thisTime;
            },
            finishProcess(row){//是否结束本次过程
                let self =this;

                 this.$confirm('是否结束本次任务过程?', '提示', {
                    confirmButtonClass: 'el-button--warning'
                }).then(() => {
                    row.endDate=self.getNowTime();
                    api.addUpdateTastDetail('update',row).then(res=>{
                        self.getProcessStateData();
                        self.$message.success(`本次过程结束成功！`)
                    })
                }).catch(() => {
                });
            },
            submitProcessStateList(fromName) {//任务过程信息-添加和编辑
                let self = this;
                let urlType= self.dialogProcessStateTitle === '添加'?'insert':'update';
                self.dialogProcessStateList.startDate =  self.dialogProcessStateList.isNowTime=='1' ? self.dialogProcessStateList.startDate : self.timestampToTime(self.dialogProcessStateList.startDate);
                self.dialogProcessStateList.endDate = self.timestampToTime(self.dialogProcessStateList.endDate);
                self.$refs[fromName].validate((valid)=>{
                    if(valid){
                        if(self.dialogProcessStateList.endDate!=''){
                            let start = self.timestampToTime(self.dialogProcessStateList.startDate).substr(0, 10);
                            let end = self.timestampToTime(self.dialogProcessStateList.endDate).substr(0, 10);
                            let date1 = new Date(self.dialogProcessStateList.startDate).getTime();
                            let date2 = new Date(self.dialogProcessStateList.endDate).getTime();
                            if(start !== end){
                                 self.$message.error('开始时间和结束时间需要同一天!');
                                 return false
                            }
                            if(date1 > date2){
                                self.$message.error('开始时间必须早于结束时间!');
                                return false;
                            }
                        }
                        api.addUpdateTastDetail(urlType,self.dialogProcessStateList).then(res=>{
                            self.isProcessStateDialog = false;
                            self.getProcessStateData();
                            self.$message.success(`${self.dialogProcessStateTitle}成功！`)

                        });
                    }
                })
            },


            //任务说明
            getMissionData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/operation/taskManagerinfo/selectByTid/1/' + _this.dialogList.id  + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.missionData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            insertMissionList() {
                this.isMissionDialog = true;
                this.dialogMissionTitle = '添加';
                this.dialogMissionList = {
                    content: '',
                    id: '',
                    object: '',
                    person: '',
                    personName: '',
                    time: '',
                    type: '',
                    tid: this.dialogList.id,
                };
            },
            updateMissionList(row) {
                this.isMissionDialog = true;
                this.dialogMissionTitle = '编辑';
                this.dialogMissionList = row;
            },
            submitMissionList() {
                let _this = this;
                let url;
                if (_this.dialogMissionTitle === '添加') {
                    url = '/api/adscm/operation/taskManagerinfo/insert/1?tokenId=' + _this.tokenId;
                } else if (_this.dialogMissionTitle === '编辑') {
                    url = '/api/adscm/operation/taskManagerinfo/update?tokenId=' + _this.tokenId;
                }

                _this.dialogMissionBtn = false;

                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogMissionList,
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isMissionDialog = false;
                        _this.getMissionData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                    _this.dialogMissionBtn = true;
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.dialogMissionBtn = true;
                })
            },

            //任务接收说明
            getMissionReceiveData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/operation/taskManagerinfo/selectByTid/2/' + _this.dialogList.id  + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.missionReceiveData = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            insertMissionReceiveList() {
                this.isMissionReceiveDialog = true;
                this.dialogMissionReceiveTitle = '添加';
                this.dialogMissionReceiveList = {
                    content: '',
                    id: '',
                    object: '',
                    person: '',
                    personName: '',
                    time: '',
                    type: '',
                    tid: this.dialogList.id,
                };
            },
            updateMissionReceiveList(row) {
                this.isMissionReceiveDialog = true;
                this.dialogMissionReceiveTitle = '编辑';
                this.dialogMissionReceiveList = row;
            },
            submitMissionReceiveList() {
                let _this = this;
                let url;
                if (_this.dialogMissionReceiveTitle === '添加') {
                    url = '/api/adscm/operation/taskManagerinfo/insert/2?tokenId=' + _this.tokenId;
                } else if (_this.dialogMissionReceiveTitle === '编辑') {
                    url = '/api/adscm/operation/taskManagerinfo/update?tokenId=' + _this.tokenId;
                }
                _this.dialogMissionReceiveBtn = false;
                this.$http({
                    url: url,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                    data: _this.dialogMissionReceiveList,
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.isMissionReceiveDialog = false;
                        _this.getMissionReceiveData();
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                    _this.dialogMissionReceiveBtn = true;
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                    _this.dialogMissionReceiveBtn = true;
                })
            },


            // 使用说明
            getJurisdiction() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/system/menu/getMenuAllSrc/' + _this.menuId + '?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        for (let i = 0; i < res.data.content.length; i++) {
                            let item = res.data.content[i];
                            _this.jurisdiction[item.component] = item.menuShow;
                        }
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            openInstructions(){
                this.isInstructionsDialog = true;
                this.drawingPage = 1;
                this.instructionsPage = 1;
                this.tableDialogData.drawingSrc = Ip + '/adscm/operation/jySoftDescription/view/1?tokenId=' + this.tokenId;
            },
            submitInstructions(){
                this.$refs.uploadDraw.submit();
                this.appendixUrl = '/api/adscm/operation/jySoftDescription/upload/1?tokenId=' + this.tokenId;
                console.log( this.appendixUrl )

            },
            uploadDrawSuccess(response, file, fileList) {
                if (response.statusCode == 200) {
                    this.tableDialogData.drawingPath = response.content;
                    this.$refs.uploadDraw.clearFiles();
                    this.tableDialogData.drawingSrc = "";
                    this.isInstructionsDialog = false;
                } else {
                    this.$message.error(response.desc)
                }
            },
            uploadDrawError(response, file, fileList) {
                this.$message.error(response);
            },
            downloadAppendixPDF() {
                window.location.href = "/api/adscm/operation/jySoftDescription/downloadPdf/1";
            },


            tableRowClassName({row, rowIndex}) {



                if (this.menuId==='4594') {
                    if (row.isPerformerUpdate){
                        if (row.isPerformerUpdate == 1){
                            return 'success-row';
                        }
                    }
                } else if (this.menuId==='4592') {
                    if (row.isCreatorUpdate){
                        if (row.isCreatorUpdate == 1){
                            return 'success-row';
                        }
                    }
                }
                return '';
            },
            handleClick(tab, event) {
                this.pagesize = 10;
                this.currentPage = 1;
                if (tab.name === '2') {
                    this.getProcessStateData();
                } else if (tab.name === '3') {
                    this.enclosureSrc = '/api/adscm/operation/taskManagerAttchment/upload?tokenId=' + this.tokenId;
                    this.getEnclosureData();
                }
            },
            handleSizeChange: function (size) {
                this.dataPagination.pagesize = size;
                if(this.menuId!="4594"){
                    this.getData()
                }
            },
            handleCurrentChange: function (currentPage) {
                this.dataPagination.pagesize = 1;
                this.dataPagination.currentPage = currentPage;
                if(this.menuId!="4594"){
                    this.getData()
                }
            },
            timestampToTime(timestamp) {
                if (timestamp) {
                    let date = new Date(timestamp);
                    let Y = date.getFullYear() + '-';
                    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
                    let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " ";
                    let h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ":";
                    let m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ":";
                    let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
                    return timestamp ? Y + M + D + h + m + s : '';
                } else {
                    return '';
                }
            },
            formatterContentHtml(row, column, value, index){
                let val;
                val =  value.replace(/<\/p>/gi,'');
                val =  val.replace(/<p>/gi,'');
                val =  val.replace(/<ul>/gi,'');
                val =  val.replace(/<\/ul>/gi,'');
                val =  val.replace(/<li>/gi,'');
                val =  val.replace(/<\/li>/gi,'');
                val =  val.replace(/<br>/gi,'');
                val =  val.replace(/&nbsp;/gi,'');
                val =  val.replace(/<b>/gi,'');
                val =  val.replace(/<\/b>/gi,'');
                return val;
            }
        }
    }
</script>

<style scoped>

    #parts .el-table--small {
        font-size: 13px;
    }

    #parts .el-table .cell,
    #parts .el-table th div {
        padding-left: 0;
        padding-right: 0;
    }

    #parts .el-tab-pane.dialog1 .el-form {
        margin-bottom: 30px;
    }


    #parts .el-table .warning-row {
        background: oldlace;
    }

    #parts .el-table .success-row {
        background: #f0f9eb;
    }

    .date-checked {
        transform: translate(86px, 8px);
        z-index: 666;
    }

    .start-date {
        transform: translateX(-20px);
    }

    .task .ql-container {
        min-height: 200px;
    }
</style>
